package com.changgou.service.goods.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .pathMapping("/")//访问资源路径
                .select()
//指定根据那个包下的controller生成swagger
                .apis(RequestHandlerSelectors.basePackage("com.changgou.service.goods.controller"))
                .paths(PathSelectors.any())//固定写法，将所有请求都配置到swagger文档里面来
                .build().apiInfo(new ApiInfoBuilder()
                        .title("畅购接口文档--Goods微服务")
                        .description("Goods微服务接口文档")
                        .version("1.0")//根据公司定
                        .build());
    }
}